package com.es.spring_es.config;

import com.es.spring_es.services.DriverlocationMainServices;
import com.es.spring_es.services.DriverlocationServices;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationListener;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.event.ContextRefreshedEvent;


/**
 * 程序完全启动后执行
 */
@Configuration
public class ApplicationStartup implements ApplicationListener<ContextRefreshedEvent> {

    @Autowired
    DriverlocationServices driverlocationServices;

    @Autowired
    DriverlocationMainServices driverlocationMainServices;

    @Override
    public void onApplicationEvent(ContextRefreshedEvent event) {
        initEsMapping();
    }

    /**
     * 初始化es表结构
     */
    private void initEsMapping(){

        driverlocationServices.testCreateIndice();

        driverlocationMainServices.CreateDriverLocationMainIndice();
    }


}
